Skip to content

Improvements for sample app#121

Open
lisajulia wants to merge 1 commit into
mainfrom
enhance/sample-app
Open

Improvements for sample app#121
lisajulia wants to merge 1 commit into
mainfrom
enhance/sample-app

Conversation

@lisajulia

Copy link
Copy Markdown
Contributor
  • extract supplier correctly
  • turn off recommendations for status field

- extract supplier correctly
- turn off recommendations for status field
@lisajulia
lisajulia requested a review from a team as a code owner July 17, 2026 07:05
@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Sample App: Supplier Extraction & Status Recommendation Improvements

Bug Fix / New Feature

🛠️ Improved the bookshop sample app with two key enhancements: correct supplier matching from extracted invoice data and disabling UI recommendations for the status field.

Changes

  • fiori-service.cds: Added field title annotations (invoiceNumber, supplier, status) to SupplierInvoices for proper i18n label resolution in the UI.
  • schema.cds: Annotated SupplierInvoices.status with @UI.RecommendationState: 0 to turn off AI-driven recommendations for that field.
  • sap.capire.bookshop-Suppliers.csv: Added a new supplier entry (Studio Salford) for test data coverage.
  • pom.xml: Bumped cds-feature-sap-document-ai dependency version from 0.0.1-alpha to 0.0.2-alpha.
  • DocumentExtractionResultHandler.java:
    • Added imports for Suppliers, Suppliers_, Select, Optional, and Locale.
    • Extracts senderName from the DIE header fields and attempts to match it case-insensitively against existing Suppliers records via the new findSupplierByName method.
    • On a successful match, sets the supplierId on the invoice update; logs a warning if no match is found.
    • Updated log message to include the extracted sender name.
    • Updated Javadoc to reflect the supplier matching addition.

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.28.0

  • File Content Strategy: Full file content
  • Output Template: Default Template
  • LLM: anthropic--claude-4.6-sonnet
  • Summary Prompt: Default Prompt
  • Event Trigger: pull_request.opened
  • Correlation ID: dd0f0370-81ad-11f1-9a3d-6a352c785d60

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR introduces four issues worth addressing: an invalid email in the CSV seed data, a full-table-scan supplier lookup that should push filtering to the database, redundant @title annotations that duplicate existing inline labels, and a @UI.RecommendationState: 0 annotation that doesn't actually disable recommendations as the PR description claims.

PR Bot Information

Version: 1.28.0

  • LLM: anthropic--claude-4.6-sonnet
  • Correlation ID: dd0f0370-81ad-11f1-9a3d-6a352c785d60
  • File Content Strategy: Full file content
  • Event Trigger: pull_request.opened

c2f3d4e5-6a7b-8c9d-0e1f-2a3b4c5d6e7f;O'Reilly Media;US;invoices@oreilly.com
d3a4b5c6-7d8e-9f0a-1b2c-3d4e5f6a7b8c;Elsevier;NL;ap@elsevier.com
e4b5c6d7-8e9f-0a1b-2c3d-4e5f6a7b8c9d;Pearson Education;GB;finance@pearson.com
e4b5c6d7-8e9f-0a1b-2c3d-4e5f6a7b8c9f;Studio Salford;US;@pearson.com

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Invalid email address for new supplier entry

The email value @pearson.com is missing the local part before the @ sign, making it an invalid email address. This will likely cause validation errors or be rejected by email-handling logic.

Consider providing a valid email address such as ap@studiosalford.com.

Suggested change
e4b5c6d7-8e9f-0a1b-2c3d-4e5f6a7b8c9f;Studio Salford;US;@pearson.com
e4b5c6d7-8e9f-0a1b-2c3d-4e5f6a7b8c9f;Studio Salford;US;ap@studiosalford.com

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful


private Optional<Suppliers> findSupplierByName(String name) {
String normalized = name.toLowerCase(Locale.ROOT);
return db.run(Select.from(Suppliers_.class))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance: findSupplierByName fetches the entire Suppliers table into memory to do a case-insensitive name match in Java.

For even a modest number of suppliers this is wasteful — every extraction event loads all supplier rows. The filter should be pushed down to the database using a where clause with a lower-case comparison, or at minimum a where(s -> s.name().eq(name)) combined with post-filter. Consider:

return db.run(Select.from(Suppliers_.class)
        .where(s -> s.name().eq(name)))
    .listOf(Suppliers.class)
    .stream()
    .filter(s -> s.getName() != null && normalized.equals(s.getName().toLowerCase(Locale.ROOT)))
    .findFirst();

This at least avoids a full-table scan for exact matches and falls back to the in-memory case-insensitive check only when needed.

Suggested change
return db.run(Select.from(Suppliers_.class))
return db.run(Select.from(Suppliers_.class)
.where(s -> s.name().eq(name)))
.listOf(Suppliers.class)
.stream()
.filter(s -> s.getName() != null && normalized.equals(s.getName().toLowerCase(Locale.ROOT)))
.findFirst();

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

Comment on lines +70 to +74
annotate service.SupplierInvoices with {
invoiceNumber @title: '{i18n>InvoiceNumber}';
supplier @title: '{i18n>Supplier}';
status @title: '{i18n>Status}';
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best Practices: The new @title annotations for invoiceNumber, supplier, and status duplicate labels already defined inline on every LineItem and FieldGroup entry in the same file.

@title on a property acts as a default label and is useful when no explicit Label is provided. Since all existing LineItem and FieldGroup data fields already carry explicit Label keys that match these titles, this block adds no functional value and creates a maintenance risk (two places to update labels). Consider removing the block or replacing the per-field Label: properties with this single source of truth instead.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

Comment thread samples/bookshop/db/schema.cds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant